using System;
using System.ComponentModel;
using System.IO;

namespace CacheLoader
{
    /// <summary>
    /// The basic cache item. 
    /// Can be dll or xap. 
    /// </summary>
    public class CacheItem : NotifyObject
    {
        private PartStatus _status;
        public PartStatus Status
        {
            get { return _status; }
            set
            {
                _status = value; OnPropertyChanged("Status");
            }
        }
        /// <summary>
        /// Gets or sets the path on the server.
        /// </summary>
        /// <value>The path.</value>
        public string Path { get; set; }

        /// <summary>
        /// Gets or sets the name of the item.
        /// </summary>
        /// <value>The name of the item.</value>
        public string ItemName { get; set; }

        /// <summary>
        /// Gets or sets the version.
        /// Should be in System.Version format.
        /// </summary>
        /// <value>The version.</value>
        public string Version { get; set; }

        /// <summary>
        /// Gets or sets the local path in isolated storage.
        /// </summary>
        /// <value>The local path.</value>
        public string LocalPath { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="CacheItem"/> is loaded.
        /// </summary>
        /// <value><c>true</c> if loaded; otherwise, <c>false</c>.</value>
        public bool Cached { get; set; }

        /// <summary>
        /// Gets or sets the item stream.
        /// </summary>
        /// <value>The item stream.</value>
        public Stream ItemStream { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="CacheItem"/> is stored.
        /// </summary>
        /// <value><c>true</c> if stored; otherwise, <c>false</c>.</value>
        public bool Stored { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether [need refresh].
        /// </summary>
        /// <value><c>true</c> if [need refresh]; otherwise, <c>false</c>.</value>
        public bool NeedRefresh { get; set; }

    }

    public enum PartStatus
    {
        Downloading,
        LoadingToMemory,
        Complete
    }
}